﻿using protoNet;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using VitServer;
using xbUI;

public class SignUp : MonoBehaviour
{
    [SerializeField] private GameObject board_signIn;
    [SerializeField] private InputField text_account;
    [SerializeField] private InputField text_password;
    [SerializeField] private InputField text_password_check;

    void Start()
    {
        MsgReader.OnMessageRecieved(GAME_PROTOCOL_MSG_ID.ID_S2C_ERROR_CODE, OnErrorCode);
    }
    
    void Update()
    {

    }

    public void OnClickCancel()
    {
        board_signIn.SetActive(true);
        gameObject.SetActive(false);
    }

    public void OnClickRegister()
    {
        string account = text_account.text;
        string password = text_password.text;
        string password_check = text_password_check.text;
        if (password == password_check)
        {
            MsgSender.SendID_C2S_REGISTER(account, password);
        }
        else
        {
            DialogManager.Instance.ShowDialog1("请确认输入两次相同的密码");
        }
    }
    private void OnErrorCode(object message)
    {
        MsgErrorCodeRep mes = (MsgErrorCodeRep)message;
        _G.Print(mes.code.ToString());
        _G.Print(mes.str);
        _G.Print(mes.type.ToString());
        _G.Print("ErrorText.OnErrorCode has called");
    }
}
